<?php
/**
 * Created by phpstorem.
 * User: yangakw@qq.com
 * Sign: 猥琐发育，别浪
 * Date: 2017/10/5 0005
 * Time: 下午 9:49
 */

namespace src;


class Queue
{
    public static $doing_data=[];
    public static $done_data=[];
    public static $error_data=[];

    /**
     * 执行对象
     * @param $obj
     * @return array
     */
    public static function  doing($obj=null){
        if($obj instanceof Item){
            self::$doing_data[$obj->hash]=$obj;
        }
        return self::$doing_data;
    }

    /**
     * 完成对象
     * @param $obj
     * @return array
     */
    public static function  done($obj=null){
        if($obj instanceof Item){
            self::$done_data[$obj->hash]=$obj;
            unset(self::$doing_data[$obj->hash]);
        }
        return self::$done_data;
    }

    /**
     * @param null $obj
     * @param string $msg
     * @return array
     */
    public static function error( $obj=null,$msg="find error"){
        if($obj instanceof Item){
            $obj->err_msg=$msg;
            self::$error_data[$obj->hash]=$obj;
            unset(self::$doing_data[$obj->hash]);
        }
        return self::$error_data;
    }
}